home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1998 August / PC Plus SuperCD 50b Issue 142 (CD142b) (August 1998).iso / handson / Java / sc20form.jar / com / supercede / forms / SuperCedeFrame.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-01-28  |  6.6 KB  |  261 lines

  1. package com.supercede.forms;
  2.  
  3. import java.applet.Applet;
  4. import java.awt.AWTEvent;
  5. import java.awt.Component;
  6. import java.awt.Container;
  7. import java.awt.Dimension;
  8. import java.awt.Frame;
  9. import java.awt.Graphics;
  10. import java.awt.Insets;
  11. import java.awt.MenuBar;
  12. import java.awt.Point;
  13. import java.awt.event.WindowEvent;
  14. import java.io.IOException;
  15. import java.io.InvalidObjectException;
  16. import java.io.ObjectInputStream;
  17. import java.io.ObjectInputValidation;
  18. import java.io.Serializable;
  19. import java.util.Vector;
  20.  
  21. public class SuperCedeFrame extends Frame implements SuperCedeDesignContainer, Serializable, ObjectInputValidation {
  22.    SuperCedeRuntimeInfo runtimeInfo = new SuperCedeRuntimeInfo();
  23.    SuperCedeDesignInfo designInfo = new SuperCedeDesignInfo();
  24.    transient boolean designMode = false;
  25.    transient DesignModeListener formListener = null;
  26.    transient Vector scContainerListeners = null;
  27.    boolean shadowEnabled = super.isEnabled();
  28.    Point shadowLocation = new Point(0, 0);
  29.    private static final long serialVersionUID = 1013082004010516612L;
  30.    private static final int _version = 1;
  31.    private int version = 1;
  32.  
  33.    public final void initializeThis(Vector var1) throws IOException, ClassNotFoundException, ClassCastException, SuperCedeInvalidStateException {
  34.       this.designInfo = null;
  35.       this.runtimeInfo = null;
  36.       SuperCedeHelper.runTimeConstructor(this, var1);
  37.       ((Component)this).setLocation(this.shadowLocation);
  38.       ((Component)this).enableEvents(64L);
  39.       this.validateObject();
  40.    }
  41.  
  42.    public Component[] getContainedComponents() {
  43.       return ((Container)this).getComponents();
  44.    }
  45.  
  46.    public void initializeFrom(SuperCedeContainer var1) throws ClassCastException, SuperCedeInvalidStateException {
  47.       try {
  48.          this.setDesignMode(((SuperCedeDesignContainer)var1).isDesignMode());
  49.          this.setFormListener(((SuperCedeDesignContainer)var1).getFormListener());
  50.          this.runtimeInfo = var1.getRuntimeInfo();
  51.          this.designInfo = ((SuperCedeDesignContainer)var1).getDesignInfo();
  52.          SuperCedeHelper.convertContainer((Container)var1, this);
  53.          if (!this.isDesignMode()) {
  54.             this.runtimeInfo = null;
  55.             this.designInfo = null;
  56.          }
  57.       } catch (ClassCastException var3) {
  58.          throw var3;
  59.       }
  60.    }
  61.  
  62.    public SuperCedeDesignInfo getDesignInfo() {
  63.       return this.designInfo;
  64.    }
  65.  
  66.    public SuperCedeRuntimeInfo getRuntimeInfo() {
  67.       return this.runtimeInfo;
  68.    }
  69.  
  70.    public void addComponent(Component var1, Object var2) {
  71.       this.addComponent(var1, var2, -1);
  72.    }
  73.  
  74.    public void addComponent(Component var1, Object var2, int var3) {
  75.       this.add(var1, var2, var3);
  76.       this.runtimeInfo.addLayoutConstraints(var1, var2);
  77.    }
  78.  
  79.    public void add(Component var1, Object var2, int var3) {
  80.       super.add(var1, var2, var3);
  81.       if (((Component)this).isVisible() && var1 instanceof Applet) {
  82.          ((Applet)var1).start();
  83.       }
  84.  
  85.    }
  86.  
  87.    public void removeComponent(int var1) {
  88.       this.removeComponent(((Container)this).getComponent(var1));
  89.    }
  90.  
  91.    public void removeComponent(Component var1) {
  92.       this.runtimeInfo.removeLayoutConstraints(var1);
  93.       this.remove(var1);
  94.    }
  95.  
  96.    public void remove(Component var1) {
  97.       if (((Component)this).isVisible() && var1 instanceof Applet) {
  98.          ((Applet)var1).stop();
  99.       }
  100.  
  101.       super.remove(var1);
  102.    }
  103.  
  104.    public boolean isEnabled() {
  105.       return this.shadowEnabled;
  106.    }
  107.  
  108.    public void setEnabled(boolean var1) {
  109.       this.shadowEnabled = var1;
  110.       if (!this.isDesignMode()) {
  111.          super.setEnabled(var1);
  112.       }
  113.  
  114.    }
  115.  
  116.    public void paint(Graphics var1) {
  117.       if (this.formListener != null) {
  118.          this.formListener.paint(var1);
  119.       }
  120.  
  121.       super.paint(var1);
  122.    }
  123.  
  124.    public void addNotify() {
  125.       super.addNotify();
  126.       if (this.formListener != null) {
  127.          this.formListener.addedPeer();
  128.       }
  129.  
  130.    }
  131.  
  132.    public void removeNotify() {
  133.       if (this.formListener != null) {
  134.          this.formListener.removingPeer();
  135.       }
  136.  
  137.       super.removeNotify();
  138.    }
  139.  
  140.    public void setMenuBar(MenuBar var1) {
  141.       MenuBar var2 = ((Frame)this).getMenuBar();
  142.       if (var2 != var1) {
  143.          if (var2 == null || var1 == null) {
  144.             Insets var3 = ((Container)this).getInsets();
  145.             super.setMenuBar(var1);
  146.             Insets var4 = ((Container)this).getInsets();
  147.             int var5 = var4.top - var3.top;
  148.             Dimension var6 = ((Component)this).getSize();
  149.             var6.height += var5;
  150.             ((Component)this).setSize(var6);
  151.             int var7 = ((Container)this).getComponentCount();
  152.  
  153.             for(int var8 = 0; var8 < var7; ++var8) {
  154.                try {
  155.                   Component var9 = ((Container)this).getComponent(var8);
  156.                   Point var10 = var9.getLocation();
  157.                   var10.y += var5;
  158.                   var9.setLocation(var10);
  159.                } catch (ArrayIndexOutOfBoundsException var11) {
  160.                }
  161.             }
  162.  
  163.          }
  164.       }
  165.    }
  166.  
  167.    public Object getLayoutConstraints(Component var1) {
  168.       return this.runtimeInfo.getLayoutConstraints(var1);
  169.    }
  170.  
  171.    public Object getLayoutConstraints(int var1) {
  172.       return this.getLayoutConstraints(((Container)this).getComponent(var1));
  173.    }
  174.  
  175.    public void setDesignMode(boolean var1) {
  176.       this.designMode = var1;
  177.    }
  178.  
  179.    public boolean isDesignMode() {
  180.       return this.designMode;
  181.    }
  182.  
  183.    public void setFormListener(DesignModeListener var1) {
  184.       this.formListener = var1;
  185.    }
  186.  
  187.    public DesignModeListener getFormListener() {
  188.       return this.formListener;
  189.    }
  190.  
  191.    public void setVisible(boolean var1) {
  192.       if (!var1) {
  193.          SuperCedeHelper.setAppletVisibility(this, this.isDesignMode(), false);
  194.       }
  195.  
  196.       super.setVisible(var1);
  197.       if (var1) {
  198.          SuperCedeHelper.setAppletVisibility(this, this.isDesignMode(), true);
  199.       }
  200.  
  201.    }
  202.  
  203.    protected void processWindowEvent(WindowEvent var1) {
  204.       if (((AWTEvent)var1).getID() == 201 && this.scContainerListeners != null) {
  205.          SuperCedeContainerEvent var3 = new SuperCedeContainerEvent(this, 4434);
  206.          synchronized(this){}
  207.  
  208.          Vector var2;
  209.          try {
  210.             var2 = (Vector)this.scContainerListeners.clone();
  211.          } catch (Throwable var6) {
  212.             throw var6;
  213.          }
  214.  
  215.          for(int var4 = 0; var4 < var2.size(); ++var4) {
  216.             ((SuperCedeContainerListener)var2.elementAt(var4)).containerShutdown(var3);
  217.          }
  218.       }
  219.  
  220.       super.processWindowEvent(var1);
  221.    }
  222.  
  223.    public void addSuperCedeContainerListener(SuperCedeContainerListener var1) {
  224.       synchronized(this){}
  225.  
  226.       try {
  227.          if (this.scContainerListeners == null) {
  228.             this.scContainerListeners = new Vector();
  229.          }
  230.  
  231.          this.scContainerListeners.addElement(var1);
  232.       } catch (Throwable var4) {
  233.          throw var4;
  234.       }
  235.  
  236.    }
  237.  
  238.    public void removeSuperCedeContainerListener(SuperCedeContainerListener var1) {
  239.       synchronized(this){}
  240.  
  241.       try {
  242.          this.scContainerListeners.removeElement(var1);
  243.       } catch (Throwable var4) {
  244.          throw var4;
  245.       }
  246.  
  247.    }
  248.  
  249.    private void readObject(ObjectInputStream var1) throws IOException, ClassNotFoundException {
  250.       var1.defaultReadObject();
  251.  
  252.       try {
  253.          SuperCedeHelper.doDeserializationProcessing(this);
  254.       } catch (SuperCedeInvalidStateException var2) {
  255.       }
  256.    }
  257.  
  258.    public void validateObject() throws InvalidObjectException {
  259.    }
  260. }
  261.